<?php
/**
 * @property product $product
 * @property category $category
 * @property district $district
 * @property product_image $product_image
 * @property province $province
 * @property user $user
 * @property area_unit $area_unit
 * @property price_unit $price_unit
 * @property orientation $orientation
 * @property CI_DB_active_record $db
 * @property CI_DB_forge $dbforge
 * @property CI_Benchmark $benchmark
 * @property CI_Calendar $calendar
 * @property CI_Cart $cart
 * @property CI_Config $config
 * @property CI_Controller $controller
 * @property CI_Email $email
 * @property CI_Encrypt $encrypt
 * @property CI_Exceptions $exceptions
 * @property CI_Form_validation $form_validation
 * @property CI_Ftp $ftp
 * @property CI_Hooks $hooks
 * @property CI_Image_lib $image_lib
 * @property CI_Input $input
 * @property CI_Lang $lang
 * @property CI_Loader $load
 * @property CI_Log $log
 * @property CI_Model $model
 * @property CI_Output $output
 * @property CI_Pagination $pagination
 * @property CI_Parser $parser
 * @property CI_Profiler $profiler
 * @property CI_Router $router
 * @property CI_Session $session
 * @property CI_Sha1 $sha1
 * @property CI_Table $table
 * @property CI_Trackback $trackback
 * @property CI_Typography $typography
 * @property CI_Unit_test $unit_test
 * @property CI_Upload $upload
 * @property CI_URI $uri
 * @property CI_User_agent $user_agent
 * @property CI_Validation $validation
 * @property CI_Xmlrpc $xmlrpc
 * @property CI_Xmlrpcs $xmlrpcs
 * @property CI_Zip $zip
 * @property CI_Javascript $javascript
 * @property CI_Jquery $jquery
 * @property CI_Utf8 $utf8
 * @property CI_Security $security
 * @property information $information
 * @property check_in_log $check_in_log
 */
class MY_model extends CI_Model
{
    public static function clone_object($source,$dest)
    {
        foreach($source as $key => $value)
        {
            $dest->$key = $value;
        }
    }

    // Private method
    public function __get($key)
    {
        if(method_exists($this,$MethodName='get_'.$key)) return $this->$MethodName();
        $CI =& get_instance();
        return $CI->$key;
    }

    // Private method
    public function to_domain_models($array)
    {
        $result = array();
        foreach($array as $item)
        {
            $result[] = $this->to_domain_model($item);
        }
        return $result;
    }

    public function to_domain_model($item)
    {
        // reserved for overloading
    }
}